//
//  ClassificationSearchView.m
//  tryshopping.boss
//
//  Created by Mr.Lee on 2016/12/13.
//  Copyright © 2016年 Reabam. All rights reserved.
//

#import "ClassificationSearchView.h"
@interface ClassificationSearchView ()
/** <#desc#> */
@property (nonatomic, weak) UIImageView *sousuoView;
/** <#desc#> */
//@property (nonatomic, weak)  UIButton *searchBtn;
@end
@implementation ClassificationSearchView

- (void)awakeFromNib{
    [super awakeFromNib];
    
    self.backgroundColor = [UIColor clearColor];
    [self setUpUI];
    
    
}

- (void)setUpUI{
    
    
    self.searchWoldTF.placeholder = @"搜索商户名";
    //设置背景图片圆角
    self.bgImage.backgroundColor = lanse3;//[UIColor colorWithHexString:@"f4f4f4"];
    self.bgImage.layer.cornerRadius = 15;
    self.bgImage.layer.masksToBounds = YES;
    
    // 添加背景框中的小
    UIImageView *sousuoView = [[UIImageView alloc] init];
    sousuoView.image = [UIImage imageNamed:@"sousuo"];
    self.sousuoView = sousuoView;
    [self.bgImage addSubview:sousuoView];
    
    // 添加按钮
//    UIButton *searchBtn = [[UIButton alloc] init];
//    [searchBtn setBackgroundColor:[UIColor clearColor]];
//    [searchBtn addTarget:self action:@selector(search:) forControlEvents:UIControlEventTouchUpInside];
//    self.searchBtn = searchBtn;
//    [self addSubview:searchBtn];
}

- (void)layoutSubviews{
    [super layoutSubviews];
    [self.sousuoView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bgImage).with.offset(10);
        make.centerY.equalTo(self.bgImage.mas_centerY);
        make.height.equalTo(@20);
        make.width.equalTo(@20);
//        make.right.equalTo(self.bgImage).with.offset(10);
    }];
    
//    [self.searchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.bgImage).with.offset(0);
//        make.centerY.equalTo(self.bgImage.mas_centerY);
//        make.height.equalTo(self.bgImage.mas_height);
//        make.width.equalTo(self.bgImage.mas_width);
//    }];
}


- (void)search:(UIButton *)btn{
    if ([self.delegate respondsToSelector:@selector(searchBtnClick:)]) {
        [self.delegate searchBtnClick:btn];
    }
}


// iOS 11 之后重写次方法
- (CGSize)intrinsicContentSize
{
    return CGSizeMake(ScreenWidth - 40*2, 30);
}

/** 实例化 */
+ (instancetype)classificationNavBar{
    return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil] firstObject];
}
@end
